import request from '../utils/request'
import store from '@/store'
console.log(store.state.token)
// 首页- 获取频道
const getUserChannelListAPI = () => {
  return request({
    url: '/v1_0/user/channels',
    method: 'GET',
    headers: {
      Authorization: `Bearer ${store.state.token}`
    }
  })
}
// 首页- 获取文章列表

const getArticleListAPI = ({ channelId, timestamp = Date.now() + '' }) => {
  return request({
    url: '/v1_0/articles',
    method: 'GET',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}
// 首页-文章不感兴趣
const articleDislikeAPI = ({ artId }) => {
  return request({
    url: '/v1_0/article/dislikes',
    method: 'post',
    data: {
      target: artId
    },
    headers: {
      Authorization: `Bearer ${store.state.token}`
    }
  })
}

const articleReportsAPI = ({ artId, type, remark }) => {
  return request({
    url: '/v1_0/article/reports',
    method: 'POST',
    headers: {
      Authorization: `Bearer ${store.state.token}`
    },
    data: {
      target: artId,
      type,
      remark: type === 0 ? remark : remark || null
    }
  })
}
export {
  getUserChannelListAPI,
  getArticleListAPI,
  articleDislikeAPI,
  articleReportsAPI
}
